package com.sduept.nwld.primaryequipment.rest;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sduept.bigdata.fault.transformer.model.TransformerAllTapRatioShortShockInfo;
import com.sduept.bigdata.fault.transformer.service.TransformerFaultQueryManager;
import com.sduept.core.dao.SuperDAO;
import com.sduept.utils.DateUtil;

import net.sf.json.JSONArray;
@RestController
@RequestMapping("/transformerFault")
public class TransformerFaultService {
	@Autowired
	private SuperDAO dao;
	@Autowired
	private TransformerFaultQueryManager tfqm;
	

	@GetMapping("/getTransformerShortShockInfoByStationAndDate/{stationId}/{start}/{end}")
	public String getTransformerShortShockInfoByStationAndDate(
			@PathVariable("stationId") String stationId,@PathVariable("start") String start,
			@PathVariable("end") String end){
		Date startDate = DateUtil.getDateByString(start+" 00:00:00", DateUtil.pattern_ymdhms);
		Date endDate = DateUtil.getDateByString(end+" 23:59:59", DateUtil.pattern_ymdhms);
	//	List<TransformerShortShockInfo> result = tfqm.getTransformerShortShockInfoByStationAndDate(stationId,startDate,endDate);
		List<TransformerAllTapRatioShortShockInfo> result = tfqm.getTransformerAllTapRatioShortShockInfoByStationAndDate(stationId, startDate, endDate);
		return JSONArray.fromObject(result).toString();
	}

	@GetMapping("/getTransformerShortShockInfoByDate/{start}/{end}")
	public String getTransformerShortShockInfoByDate(@PathVariable("start") String start,
			@PathVariable("end") String end){
		Date startDate = DateUtil.getDateByString(start+" 00:00:00", DateUtil.pattern_ymdhms);
		Date endDate = DateUtil.getDateByString(end+" 23:59:59", DateUtil.pattern_ymdhms);
	//	List<TransformerShortShockInfo> result = tfqm.getTransformerShortShockInfoByStationAndDate(null,startDate,endDate);
		List<TransformerAllTapRatioShortShockInfo> result = tfqm.getTransformerAllTapRatioShortShockInfoByStationAndDate(null, startDate, endDate);
		return JSONArray.fromObject(result).toString();
	}
}
